package com.ccrfid.rmc6.entity.device;

import com.ccrfid.rmc6.appconfig.jackson.CustomDouble2Serialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.sql.Timestamp;

@Entity
@Table(name = "d_card")
public class CardEntity {
    private Long id;
    private Long uid;
    private String sn;
    private Long cardNumber;
    private String hexNumber;
    private Integer cardType;
    private Integer onlineStatus;
    private Integer cutoffStatus;
    private Integer lowpowerStatus;
    private Integer enabled;
    @JsonSerialize(using = CustomDouble2Serialize.class)
    private Double battery;
    private Integer heartRate;
    private Integer firmwareVersion;
    private Timestamp createTime;
    private Timestamp updateTime;

    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Basic
    @Column(name = "uid", nullable = true)
    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    @Basic
    @Column(name = "sn", nullable = true, length = 32)
    public String getSn() {
        return sn;
    }

    public void setSn(String sn) {
        this.sn = sn;
    }

    @Basic
    @Column(name = "card_number", nullable = false)
    public Long getCardNumber() {
        return cardNumber;
    }

    public void setCardNumber(Long cardNumber) {
        this.cardNumber = cardNumber;
    }

    @Basic
    @Column(name = "hex_number", length = 32)
    public String getHexNumber() {
        return hexNumber;
    }

    public void setHexNumber(String hexNumber) {
        this.hexNumber = hexNumber;
    }

    @Basic
    @Column(name = "card_type", nullable = false)
    public Integer getCardType() {
        return cardType;
    }

    public void setCardType(Integer cardType) {
        this.cardType = cardType;
    }

    @Basic
    @Column(name = "online_status", nullable = true)
    public Integer getOnlineStatus() {
        return onlineStatus;
    }

    public void setOnlineStatus(Integer onlineStatus) {
        this.onlineStatus = onlineStatus;
    }

    @Basic
    @Column(name = "cutoff_status", nullable = true)
    public Integer getCutoffStatus() {
        return cutoffStatus;
    }

    public void setCutoffStatus(Integer cutoffStatus) {
        this.cutoffStatus = cutoffStatus;
    }

    @Basic
    @Column(name = "lowpower_status", nullable = true)
    public Integer getLowpowerStatus() {
        return lowpowerStatus;
    }

    public void setLowpowerStatus(Integer lowpowerStatus) {
        this.lowpowerStatus = lowpowerStatus;
    }

    @Basic
    @Column(name = "is_enabled", nullable = false)
    public Integer getEnabled() {
        return enabled;
    }

    public void setEnabled(Integer enabled) {
        this.enabled = enabled;
    }

    @Basic
    @Column(name = "battery", nullable = true, precision = 0)
    public Double getBattery() {
        return battery;
    }

    public void setBattery(Double battery) {
        this.battery = battery;
    }

    @Basic
    @Column(name = "heart_rate", nullable = true)
    public Integer getHeartRate() {
        return heartRate;
    }

    public void setHeartRate(Integer heartRate) {
        this.heartRate = heartRate;
    }

    @Basic
    @Column(name = "firmware_version", nullable = true)
    public Integer getFirmwareVersion() {
        return firmwareVersion;
    }

    public void setFirmwareVersion(Integer firmwareVersion) {
        this.firmwareVersion = firmwareVersion;
    }

    @Basic
    @Column(name = "create_time", nullable = false)
    @CreationTimestamp
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = false)
    @UpdateTimestamp
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }
}
